import matplotlib.pyplot as plt
import sys
import os
import glob

path_doc = sys.argv[1]
olg = sys.argv[2]

g = os.path.join(path_doc,'%s_*'%olg)
print g
d = {}

for p in glob.glob(g) :
  fn = os.path.split(p)[-1][:-4]
  lg,ratio,precision,recall,f_measure = fn.split("_")
  if lg != olg :
    continue
  d[float(ratio)] = (float(precision),float(recall),float(f_measure))
#  lg,ratio,precision,recall = p.split("")
#  print p

list_x = []
list_recall = []
list_precision = []
list_f_measure = []

for r in sorted(d.keys()) :
  list_x.append(r)
#  list_x.append(d[r][1])
  list_precision.append(d[r][0])
  list_recall.append(d[r][1])
  list_f_measure.append(d[r][2])
  
print list_x
print list_recall
print list_precision

plt.xlabel('x')
plt.ylabel('y')
plt.plot(list_x, list_recall, 'b--')
plt.plot(list_x, list_precision, 'b-')
plt.plot(list_x, list_f_measure, 'r-')
out_filename = "out_f_%s.pdf"%olg
plt.savefig(out_filename)
